package com.example.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;

/**
 * @author YJC
 * @version V1.0
 * @description: TODO
 * @date 2020-11-10 14:34
 */
@Slf4j
@Component("elasticJobDemo")
public class ElasticJobDemo implements SimpleJob {

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("=========执行任务开始=========");
        ArrayList<Object> datas = Lists.newArrayList();
        while (true) {
            //do something
            if (CollectionUtils.isEmpty(datas)) {
                break;
            }
        }
        log.info("=========执行任务结束=========");
    }
}
